<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();//获得当前的项目根目录路径赋值给path
%>
<jsp:include page="/WEB-INF/jsp/common/header.jsp"></jsp:include>
<link rel="stylesheet" href="<%=path%>/static/css/page.css" />
<body>
<!--nav start-->
<jsp:include page="/WEB-INF/jsp/common/nav.jsp"></jsp:include>
<div class="inside_wrap" >
    <div class="inside_con" style="margin-left: 525px">
        <div class="adr">
            <a href="index.html">首页></a><a href="<%=path%>/client/tiezi">校园论坛></a>帖子详情
        </div>
        <div class="inside_box">
            <div class="topic_wrap fl">
                <div class="t_label">
                    <div class="tl_tab fl">
                        <a href="<%=path%>/client/tiezi" id="hot_week" class="active">返回</a>
                        <a href="<%=path%>/tiezi/toAdd" class="active">发布帖子</a>

                    </div>
                    <div class="search fr">
                        <form action="<%=path%>/client/tiezi" method="post" id="searchForm">
                        <input type="text" name="title" id="title" value="" placeholder="请输入帖子标题" class="input_tp" />
                        <button type="button" class="btn">搜索</button>
                        </form>
                    </div>
                </div>
                <div class="tl_con">
                    <h3>${record.title}<span class="addressor">发布日期：<fmt:formatDate value="${record.create_time}" pattern="yyyy-MM-dd HH:mm:ss"/>&nbsp;&nbsp;&nbsp;</span></h3>
                    <p>${record.content}</p>

                    <div class="reply_wrap" id="reply">
                        <div class="r_title">${comments.size()}个评论</div>
                        <ul class="talk_list">
                            <c:forEach items="${comments}" var="row">
                            <li class="backview">
                                <div class="det_l">
                                    <img src="<%=path%>/upload/${row.user.photo}"/>
                                </div>
                                <div class="li_cont">
                                    <div class="info">
                                        <span class="i_name">${row.user.nick_name}<span class="date"><fmt:formatDate value="${row.create_time}" pattern="yyyy-MM-dd HH:mm:ss"/></span></span>
                                    </div>
<%--                                    <div class="li_t editor_style">--%>
<%--                                        <p>铂金会员</p>--%>
<%--                                    </div>--%>
                                    <div class="info replyinfo">
                                        <span class="replynum" style="color: #1f0b0b">评论内容：${row.content}</span>
                                    </div>
                                    <div class="del_reply_wp">
                                        <ul class="del_repy">
                                            <c:forEach items="${row.replyList}" var="data">
                                            <li class="cl">
                                                <a href="ownTopic1.html" class="avatar"><img src="<%=path%>/upload/${data.user.photo}"/></a>
                                                <div class="cl_cont">
                                                    <div class="info">
                                                        <span class="i_name">${data.user.nick_name}<span class="date"><fmt:formatDate value="${data.create_time}" pattern="yyyy-MM-dd HH:mm:ss"/></span></span>
                                                    </div>
                                                    <div class="li_t editor_style">
                                                        <p>回复内容:${data.content}</p>
                                                    </div>
                                                </div>
                                            </li>
                                            </c:forEach>
                                        </ul>
                                        <div class="del_reply_input_cl">
                                            <form id="replyForm">
                                                <input type="hidden" name="cid" value="${row.id}">
                                                <textarea placeholder="请输入内容" name="content"></textarea>
                                                <div class="del_reply_btn">
                                                   <button type="reset" class="btn reset_btn">取消</button>
                                                    <button type="button" class="btn submit_btn" id="add">回复</button>
                                                </div>
                                                <div class="clear"></div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </li>
                          </c:forEach>
                        </ul>
                    </div>
                    <div class="editor">
                        <form action="<%=path%>/comment/add" method="post" class="layui-form">
                            <input type="hidden" name="tid" value="${record.id}">
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">评论内容</label>
                                <div class="layui-input-block">
                                    <textarea name="content" id="content" placeholder="请输入评论" class="layui-textarea"></textarea>
                                </div>
                            </div>
                            <button type="submit" class="btn submit_btn">发表评论</button>
                        </form>
                    </div>
                </div>
            </div>
            <div class="topic_list fr">

            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>

<!--footer start-->
<jsp:include page="/WEB-INF/jsp/common/footer.jsp"></jsp:include>
<script src="<%=path%>/static/js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="<%=path%>/static/js/jquery.SuperSlide.2.1.js" type="text/javascript"></script>
<script src="<%=path%>/static/js/common.js"></script>
<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','upload','jquery','laydate','layedit'], function() {
        var $ = layui.$
            , upload = layui.upload
            , form = layui.form
            , laydate = layui.laydate
            , layedit = layui.layedit;

        //执行一个laydate实例
        laydate.render({
            elem: '#create_date'//指定元素

        });
        var index = layedit.build('content',{
            tool:['strong','italic','underline','del','|','left','center','right','link','unlink']
            ,height:200

        });
    });
    $("#add").click(function () {
        $.ajax({
            cache: true,
            type: "post",
            url: "<%=path%>/reply/add",
            data: $('#replyForm').serialize(),
            async: false,
            success: function (data) {
                if (data.success) {
                    layer.msg(data.message, {
                        icon: 1,
                        time: 1000
                    }, function () {
                        document.location.reload();
                    });
                } else {
                    layer.msg(data.message, {
                        icon: 2,  // Using icon 2 for error/warning
                        time: 2000  // Showing error messages a bit longer
                    });
                }
            },
            error: function () {
                layer.msg('请求失败，请稍后重试', {
                    icon: 2,
                    time: 2000
                });
            }
        });
    });
</script>
<script>

    function doPage(pageNo) {
        document.getElementById("pageNum").value = pageNo;
        document.getElementById("searchForm").submit();
    }
    function changePageSize(cur_pageSize){
        document.getElementById("pageSize").value=cur_pageSize;
        document.getElementById("searchForm").submit();//表单提交
    }
</script>
</body>
</html>
